package com.nisum.mocksimulator.webservice;

import javax.jws.WebService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import com.nisum.mocksimulator.externalize.ExternalizableMessageWriter;
import com.nisum.mocksimulator.webservice.beans.CarType;

//Service Implementation
@WebService(endpointInterface = "com.nisum.mocksimulator.webservice.CarWebService")
@Component
public class CarWebServiceImpl implements CarWebService {
	@Value("c:\\temp\\")
	private String directory;
	@Autowired
	@Qualifier("4x2")
	private CarType car;
	@Autowired
	ExternalizableMessageWriter writer;
	
	@Override
	public CarType getCar(String name, int year) {
		car.setName(name);
		car.setYear(year);
		System.out.println("CarWebService is externalizing object: "+car.toString());
		
		writer.setDirectory(directory);
		writer.write(car);
		return car;
	}
}